﻿<catel:DataWindow x:Class="Catel.Examples.AdvancedDemo.Views.LogicInViewBase.NestedUserControlsWindow"
                  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                  xmlns:ViewModels="clr-namespace:Catel.Examples.AdvancedDemo.ViewModels"
                  xmlns:Views="clr-namespace:Catel.Examples.AdvancedDemo.Views.LogicInViewBase"
                  xmlns:catel="http://catel.codeplex.com"
                  SizeToContent="Manual" Width="500" Height="800">

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>

        <Label Grid.Row="0">
            <TextBlock TextWrapping="Wrap">
                This example shows how to use nested user controls and let each nested user control
                have it's own validation but still use the InfoBarMessageControl of the window.
                <LineBreak /><LineBreak />
                Clear the name of any house or room (which is a nested user control of a house) and see how
                the validation of a nested user control bubbles up to the InfoBarMessageControl.
                <LineBreak /><LineBreak />
                Note how the OK button gets disabled when a nested view model contains any errors.
            </TextBlock>
        </Label>

        <ScrollViewer Grid.Row="1">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="20" />
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>

                <ItemsControl Grid.Column="1" ItemsSource="{Binding Houses}">
                    <ItemsControl.ItemTemplate>
                        <DataTemplate>
                            <StackPanel>
                                <Views:HouseView DataContext="{Binding}" />
                                <Line Height="2" />
                            </StackPanel>
                        </DataTemplate>
                    </ItemsControl.ItemTemplate>
                </ItemsControl>
            </Grid>
        </ScrollViewer>
    </Grid>
</catel:DataWindow>
